let currentIndex = 0;
const items = document.querySelectorAll('.carousel-item');
const totalItems = items.length;

function showImage(index) {
    const offset = -index * 200; // 200px is the width of each item
    document.querySelector('.carousel-inner').style.transform = `translateX(${offset}px)`;
}

function nextImage() {
    currentIndex = (currentIndex + 1) % totalItems;
    showImage(currentIndex);
}

function prevImage() {
    currentIndex = (currentIndex - 1 + totalItems) % totalItems;
    showImage(currentIndex);
}

// 自动轮播
setInterval(nextImage, 3000); // Change image every 3 seconds

// 添加按钮点击事件
document.getElementById('nextButton').addEventListener('click', nextImage);
document.getElementById('prevButton').addEventListener('click', prevImage);